import axios from 'axios';

const API_URL = 'http://localhost:8000/api/inventory/';

export const getInventoryItems = () => axios.get(API_URL);
export const createInventoryItem = (item) => axios.post(API_URL, item);
export const updateInventoryItem = (id, item) => axios.put(`${API_URL}${id}/`, item);
export const deleteInventoryItem = (id) => axios.delete(`${API_URL}${id}/`);
export const receiveGoods = (goodsData) => {
    const token = localStorage.getItem('access');
    return axios.post(`${API_URL}receive_goods/`, goodsData, {
        headers: {
            'Authorization': `Bearer ${token}`, // 注意这里的 Bearer
            'Content-Type': 'application/json',
        },
    });
};
export const generateInventoryReport = () => {
    return axios.get(`${API_URL}generate_inventory_report/`)
}

export const getInventoryAlerts = () => {
    return axios.get(`${API_URL}alerts/`)
}

export const getInventoryAlertsCount = () => {
    const token = localStorage.getItem('access');
    return axios.get(`${API_URL}alerts_count/`, {
        headers: {
            'Authorization': `Bearer ${token}`
        }
    })
}